<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      // 当形参有默认值时, 函数体是一个块作用域
      function fn(a, b=function () {a=2}) {
        var c = 3
        var d = 4
        var a = 5
      }
      // fn(1, 2)
    </script>

    <script>
        var  x = 1;

        function f(x, y=function(){x=3; console.log(x)}){
            console.log(x);
            var x = 2;
            y()
            console.log(x);
        }

        f();
        console.log(x)

    </script>
</body>
</html>